package com.tdf.webblog.service;

import com.tdf.webblog.api.MySQLRemoteService;
import com.tdf.webblog.entity.AdminPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminPermissionService {
    @Autowired
    private MySQLRemoteService mySQLRemoteService;

    public boolean needFilter(String requestAPI) {
        List<AdminPermission> ps = mySQLRemoteService.findAllRemote();
        for (AdminPermission p: ps) {
            // match prefix
            if (requestAPI.startsWith(p.getUrl())) {
                return true;
            }
        }
        return false;
    }
}
